<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>微信支付中心</title>
    <script src="{:config('pay.assets.jquery')}"></script>
    <style>

        html, body {
            color: #333;
            margin: 0;
            height: 100%;
            font-family: "Myriad Set Pro", "Helvetica Neue", Helvetica, Arial, Verdana, sans-serif;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            font-weight: normal;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        a {
            text-decoration: none;
            color: #000;
        }

        a, label, button, input, select {
            -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        }

        img {
            width: 100%;
            height: auto;
            display: block;
            border: 0;
        }

        body {
            background: #f3f3f3;
            color: #666;
        }

        html, body, div, dl, dt, dd, ol, ul, li, h1, h2, h3, h4, h5, h6, p, blockquote, pre, button, fieldset, form, input, legend, textarea, th, td {
            margin: 0;
            padding: 0;
        }

        a {
            text-decoration: none;
            color: #08acee;
        }

        button {
            outline: 0;
        }

        button, input, optgroup, select, textarea {
            margin: 0;
            font: inherit;
            color: inherit;
            outline: none;
        }

        li {
            list-style: none;
        }

        a {
            color: #666;
        }

        .clearfix::after {
            clear: both;
            content: ".";
            display: block;
            height: 0;
            visibility: hidden;
        }

        .clearfix {
        }

        .divHeight {
            width: 100%;
            height: 10px;
            background: #f5f5f5;
            position: relative;
            overflow: hidden;
        }

        .r-line {
            position: relative;
        }

        .r-line:after {
            content: '';
            position: absolute;
            z-index: 0;
            top: 0;
            right: 0;
            height: 100%;
            border-right: 1px solid #D9D9D9;
            -webkit-transform: scaleX(0.5);
            transform: scaleX(0.5);
            -webkit-transform-origin: 100% 0;
            transform-origin: 100% 0;
        }

        .b-line {
            position: relative;
        }

        .b-line:after {
            content: '';
            position: absolute;
            z-index: 2;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 1px;
            border-bottom: 1px solid #e2e2e2;
            -webkit-transform: scaleY(0.5);
            transform: scaleY(0.5);
            -webkit-transform-origin: 0 100%;
            transform-origin: 0 100%;
        }

        .aui-arrow {
            position: relative;
            padding-right: 0.8rem;
            color: #7f8699;
            font-size: 0.85rem;
        }

        .aui-arrow span {
            font-size: 0.8rem;
            color: #9b9b9b;
        }

        .aui-arrow:after {
            content: " ";
            display: inline-block;
            height: 6px;
            width: 6px;
            border-width: 2px 2px 0 0;
            border-color: #848484;
            border-style: solid;
            -webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
            transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
            position: relative;
            top: -2px;
            position: absolute;
            top: 50%;
            margin-top: -6px;
            right: 2px;
            border-radius: 1px;
        }

        .aui-flex {
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-box-align: center;
            -webkit-align-items: center;
            align-items: center;
            padding: 15px;
            position: relative;
        }

        .aui-flex-box {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            min-width: 0;
            font-size: 14px;
            color: #333;
        }

        /* 必要布局样式css */
        .aui-flexView {
            width: 100%;
            height: 100%;
            margin: 0 auto;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            -webkit-flex-direction: column;
            -ms-flex-direction: column;
            flex-direction: column;
        }

        .aui-scrollView {
            width: 100%;
            height: 100%;
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            -ms-flex: 1;
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            position: relative;
            padding-bottom: 53px;
        }

        .aui-navBar {
            height: 44px;
            position: relative;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            z-index: 102;
            background: #f3f3f3;
        }

        .aui-navBar-item {
            height: 44px;
            min-width: 15%;
            -webkit-box-flex: 0;
            -webkit-flex: 0 0 15%;
            -ms-flex: 0 0 15%;
            flex: 0 0 15%;
            padding: 0 0.9rem;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -ms-flex-align: center;
            align-items: center;
            font-size: 0.7rem;
            white-space: nowrap;
            overflow: hidden;
            color: #808080;
            position: relative;
        }

        .aui-navBar-item:first-child {
            -webkit-box-ordinal-group: 2;
            -webkit-order: 1;
            -ms-flex-order: 1;
            order: 1;
            margin-right: -25%;
            font-size: 0.9rem;
            font-weight: bold;
        }

        .aui-navBar-item:last-child {
            -webkit-box-ordinal-group: 4;
            -webkit-order: 3;
            -ms-flex-order: 3;
            order: 3;
            -webkit-box-pack: end;
            -webkit-justify-content: flex-end;
            -ms-flex-pack: end;
            justify-content: flex-end;
            font-size: 14px;
            color: #333333;
        }

        .aui-center {
            -webkit-box-ordinal-group: 3;
            -webkit-order: 2;
            -ms-flex-order: 2;
            order: 2;
            display: -webkit-box;
            display: -webkit-flex;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-pack: center;
            -webkit-justify-content: center;
            -ms-flex-pack: center;
            justify-content: center;
            -webkit-box-align: center;
            -webkit-align-items: center;
            -ms-flex-align: center;
            align-items: center;
            height: 44px;
            width: 80%;
            margin-left: 22%;
        }

        .aui-center-title {
            text-align: center;
            width: 100%;
            white-space: nowrap;
            overflow: hidden;
            display: block;
            text-overflow: ellipsis;
            font-size: 0.95rem;
            color: #333;
            font-weight: bold;
        }

        .icon {
            width: 19px;
            height: 19px;
            display: block;
            border: none;
            float: left;
            background-size: 19px;
            background-repeat: no-repeat;
        }

        .aui-flex-box h1 {
            color: #303741;
            font-weight: 500;
            font-size: 1rem;
            overflow: hidden;
        }

        .aui-flex-box h2 {
            color: #303741;
            font-weight: 500;
            font-size: 1rem;
            margin-bottom: 0.8rem;
        }

        .aui-flex-box p {
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            word-break: break-all;
            text-overflow: ellipsis;
            font-size: 0.9rem;
            margin-bottom: 0.1rem;
            color: #676767;
        }

        .aui-flex-box h3 {
            font-size: 0.9rem;
            color: #8a8a8a;
            font-weight: normal;
            width: 100%;
            overflow: hidden;
            margin-bottom: 0.3rem;
        }


        .aui-palace {
            padding: 0.6rem 0;
            position: relative;
            overflow: hidden;
        }

        .aui-palace-grid {
            position: relative;
            float: left;
            padding: 1px;
            width: 33.333%;
            box-sizing: border-box;
            margin: 10px 0;
        }


        .aui-palace-grid img {
            width: 65%;
            margin: 0 auto;
        }


        .icon-return {
            background-image: url('');
        }

        .icon-more {
            background-image: url('');
        }

        .aui-pay-info {
            margin-top: 15px;
        }

        .aui-pay-info p em {
            text-align: right;
        }

        .aui-pay-info .aui-flex {
            padding: 0;
        }

        .aui-pay-fill {
            padding: 10px 15px;
        }

        .aui-pay-flex {
            width: 100%;
            border-radius: 10px;
            background: white;
            padding: 20px;
            margin-bottom: 20px;
        }

        .aui-pay-text {
            text-align: center;
            width: 100%;
            font-size: 14px;
            color: #939393;
        }

        .aui-pay-text {
            padding: 10px 0;
        }

        .aui-pay-text h2 {
            color: #333333;
            font-size: 35px;
            font-weight: normal;
            margin-top: 10px;
            margin-bottom: 5px;
        }

        .aui-pay-text h2 em {
            color: #333333;
            font-size: 20px;
            font-style: normal;
            font-weight: normal;
        }


        .aui-pay-flex .aui-flex {
            padding: 0;
        }


        .aui-pay-title {
            font-size: 18px;
            color: #333333;
            position: relative;
            padding-left: 25px;
        }

        .aui-flex-box .aui-pay-titleS {
            font-size: 18px;
            color: #333333;
            position: relative;
            padding-left: 25px;
        }

        .aui-pay-title:after {
            width: 20px;
            height: 20px;
            position: absolute;
            z-index: 0;
            top: 3px;
            left: 0;
            content: "";
            background-image: url('');
            background-size: 20px;
        }

        .aui-pay-titleS:after {
            width: 20px;
            height: 20px;
            position: absolute;
            z-index: 0;
            top: 3px;
            left: 0;
            content: "";
            background-image: url('');
            background-size: 20px;
        }

        .aui-pay-flex .aui-pay-info p {
            color: #6e6e6e;
            padding: 5px 0;
            font-size: 14px;
        }

        .aui-pay-flex .aui-pay-info p em {
            color: #333333;
            font-style: normal;
            font-size: 15px;
        }

        .aui-pay-com {
            width: 92%;
            margin: 0 auto;
        }

        .aui-pay-com button {
            background-color: #6bc3ff;
            background: -webkit-linear-gradient(to right, #6bc3ff, #0081ff);
            background: -o-linear-gradient(to right, #6bc3ff, #0081ff);
            background: -moz-linear-gradient(to right, #6bc3ff, #0081ff);
            background: linear-gradient(to right, #6bc3ff, #0081ff);
            color: white;
            border: none;
            width: 100%;
            padding: 12px 0;
            border-radius: 10px;
            font-size: 16px;
        }

        .aui-flex .info {
            flex: 3;
            text-align: right;
        }

        .aui-flex .info, .message {
            color: #6e6e6e;
            padding: 5px 0;
            font-size: 14px;
        }

        .aui-flex .message {
            overflow-x: hidden;
            white-space: nowrap;
            margin-left: 20px;
            text-overflow: ellipsis;
            flex: 9;
        }

        .aui-pay-info .message input, select {
            border: 1px solid #cccccc;
            height: 28px;
            line-height: 25px;
            width: 100%;
            text-indent: 5px;
        }

        .error-container {
            display: none;
        }
    </style>
</head>
<body>

<section class="aui-flexView">
    <section class="aui-scrollView">
        <div class="aui-pay-box">
            <div class="aui-pay-fill">
                <div class="aui-pay-flex">
                    <div class="aui-flex b-line">
                        <div class="aui-flex-box">
                            <h2>订单信息</h2>
                        </div>
                    </div>
                    <div class="aui-pay-info">

                        <div class="aui-flex">
                            <div class="info">
                                商品名称
                            </div>
                            <div class="aui-flex-box message">{$subject|default=''}</div>
                        </div>

                        <div class="aui-flex">
                            <div class="info">
                                订单编号
                            </div>
                            <div class="aui-flex-box message">{$order_no|default=''}</div>
                        </div>

                        <div class="aui-flex">
                            <div class="info">
                                订单金额
                            </div>
                            <div class="aui-flex-box message">￥{$total_amount/100}元</div>
                        </div>

                        <div class="aui-flex">
                            <div class="info">
                                支付结果
                            </div>
                            <div class="aui-flex-box message">
                                <span id="pay_result">支付中</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</section>

</body>
</html>

<script>

  let pay_no = '{$pay_no}'
  let platform_id = '{$platform_id}'
  let account = '{$account}'
  let pay_data = '{$pay_data|json_encode|raw}'
  pay_data = JSON.parse(pay_data)

  let success = function () {
    if (pay_no) {
      location.href = `/pay/success/${pay_no}`
    }
  }

  function onBridgeReady () {
    WeixinJSBridge.invoke(
      'getBrandWCPayRequest', pay_data,
      function (res) {
        if (res.err_msg === 'get_brand_wcpay_request:ok') {
          payResult('支付成功')
          setTimeout(function () {
            success()
          }, 2000)
        } else {
          payResult('支付失败')
          setTimeout(function () {
            window.close()
          }, 2000)
        }
      })
  }

  function payResult (message) {
    $('#pay_result').text(message)
  }

  if (typeof WeixinJSBridge == 'undefined') {
    if (document.addEventListener) {
      document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
    } else if (document.attachEvent) {
      document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
      document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
    }
  } else {

  }
</script>